package com.only4play.productcenter.domain.inoutrecord;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-02-27
 */
import com.only4play.codegen.processor.api.GenCreateRequest;
import com.only4play.codegen.processor.api.GenFeign;
import com.only4play.codegen.processor.api.GenQueryRequest;
import com.only4play.codegen.processor.api.GenResponse;
import com.only4play.codegen.processor.api.GenUpdateRequest;
import com.only4play.codegen.processor.controller.GenController;
import com.only4play.codegen.processor.creator.GenCreator;
import com.only4play.codegen.processor.mapper.GenMapper;
import com.only4play.codegen.processor.query.GenQuery;
import com.only4play.codegen.processor.repository.GenRepository;
import com.only4play.codegen.processor.service.GenService;
import com.only4play.codegen.processor.creator.IgnoreCreator;
import com.only4play.codegen.processor.updater.IgnoreUpdater;
import com.only4play.codegen.processor.service.GenServiceImpl;
import com.only4play.codegen.processor.updater.GenUpdater;
import com.only4play.codegen.processor.vo.GenVo;
import com.only4play.common.annotation.FieldDesc;
import com.only4play.common.constants.ValidStatus;
import com.only4play.jpa.converter.ValidStatusConverter;
import com.only4play.jpa.support.BaseJpaAggregate;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.only4play.productcenter.api.constants.DirectionType;
import com.only4play.productcenter.api.constants.InOutStoreType;
import com.only4play.productcenter.infrastructure.constants.Constants;
import com.only4play.productcenter.infrastructure.convert.DirectionTypeConverter;
import com.only4play.productcenter.infrastructure.convert.InOutStoreTypeConverter;
import lombok.Data;

@GenVo(pkgName = "com.only4play.productcenter.domain.inoutrecord.vo")
@GenCreator(pkgName = "com.only4play.productcenter.domain.inoutrecord.creator")
@GenUpdater(pkgName = "com.only4play.productcenter.domain.inoutrecord.updater")
@GenRepository(pkgName = "com.only4play.productcenter.domain.inoutrecord.repository")
@GenService(pkgName = "com.only4play.productcenter.domain.inoutrecord.service")
@GenServiceImpl(pkgName = "com.only4play.productcenter.domain.inoutrecord.service")
@GenQuery(pkgName = "com.only4play.productcenter.domain.inoutrecord.query")
@GenMapper(pkgName = "com.only4play.productcenter.domain.inoutrecord.mapper")
@GenController(pkgName = "com.only4play.productcenter.controller")
@GenCreateRequest(pkgName = "com.only4play.productcenter.api.inoutrecord.request",sourcePath = Constants.GEN_API_SOURCE)
@GenUpdateRequest(pkgName = "com.only4play.productcenter.api.inoutrecord.request",sourcePath = Constants.GEN_API_SOURCE)
@GenQueryRequest(pkgName = "com.only4play.productcenter.api.inoutrecord.request",sourcePath = Constants.GEN_API_SOURCE)
@GenResponse(pkgName = "com.only4play.productcenter.api.inoutrecord.response",sourcePath = Constants.GEN_API_SOURCE)
@GenFeign(pkgName = "com.only4play.productcenter.api.inoutrecord.service",sourcePath = Constants.GEN_API_SOURCE,serverName ="product-srv")
@Entity
@Table(name = "in_out_record")
@Data
/**
 * 相当于仓库管理员
 */
public class InOutRecord extends BaseJpaAggregate {

  
  @FieldDesc(name = "仓库id")
  private Long storeId;

  @FieldDesc(name = "出入库类型")
  @Convert(converter = InOutStoreTypeConverter.class)
  private InOutStoreType inOutStoreType;

  @FieldDesc(name = "出入库方向")
  @Convert(converter = DirectionTypeConverter.class)
  private DirectionType directionType;
  
  @FieldDesc(name = "批次号")
  private String batchNo;

  @FieldDesc(name = "数量")
  private Integer count;

  @Convert(converter = ValidStatusConverter.class)
  @IgnoreUpdater
  @IgnoreCreator
  private ValidStatus validStatus;

  public void init() {
    setValidStatus(ValidStatus.VALID);
  }

  public void valid(){
    setValidStatus(ValidStatus.VALID);
  }

  public void invalid(){
    setValidStatus(ValidStatus.INVALID);
  }
}
